2
תגובות

טופס העלאת תמונה

פתח phpon ,
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="he" >
<head>
<title>Stepping Through an Array </title>
<link rel="stylesheet" type="text/css" href="common.css" />

</head>
<body>

<?php

if ( isset( $_POST["sendPhoto"] ) ) {
  processForm();
} else {
  displayForm();
}

function processForm() {
  if ( isset( $_FILES["photo"] ) and $_FILES["photo"]["error"] ==
UPLOAD_ERR_OK ) {
    if ( $_FILES["photo"]["type"] != "image/jpeg" ) {
    echo "<p>only Jepg photos!</p>";
  } elseif ( !move_uploaded_file( $_FILES["photo"]["tmp_name"],
"photos/" . basename( $_FILES["photo"]["name"] ) ) ) {
      echo "<p>Sorry, there was a problem uploading that photo.</p>" .
$_FILES["photo"]["error"] ;
    } else {
    dipslayThanks();
  }
  } else {
    switch( $_FILES["photo"]["error"] ) {
    case UPLOAD_ERR_INI_SIZE:
      $message = "the photo is larger than the server allows.";
    break;
    case UPLOAD_ERR_FORM_SIZE:
      $message = "the photo is larger than the script allows.";
      break;
    case UPLOAD_ERR_NO_FILE:
      $message = "No file eas uploaded. Make sure you choos a file to upload.";
      break;
    default:
      $message = "Please contact your server administrator for help.";
  }
  echo "<p>Sorry, there was a problem uploading that photo. $message</p>";
  }
}


function displayForm() {
?>
    <h1>Uploading a Photo</h1>
    <p>Please enter your name and choose a photo to upload, then click
Send Photo.</p>

    <form action="files.php" method="post" enctype="multipart/form-data">
    <div style="width: 30em;">
      <input type="hidden" name="MAX_FILE_SIZE" value="50000" />
   
    <label for="visitorName">Your name</label>
    <input type="text" name="visitorName" id="visitorName" value="" />
       
    <label for="photo">Your photo</label>
    <input type="file" name="photo" id="photo" value="" />
       
    <div style="clear: both;">
      <input type="submit" name="sendPhoto" value="Send Photo" />
    </div>
    </div>
  </form>
<?php
}

function displayThanks() {
?>

<h1>Thank You</h1>
<p>Thanks for uploading your photo<?php if ( $_POST["visitorName"] )

echo ", " . $_POST["visitorName"] ?>!</p>
<p>Here’s your photo:</p>    
<p><img src="photos/<?php echo $_FILES["photo"]["name"] ?>" alt="Photo" />
</p>
<?php
}
?>

  </body>
</html>



הבעייה היא בשורה 25 move_iploaded_file משהו כזה..( ! ) Warning: move_uploaded_file(wamp/images.jpg): failed to open stream: No such file or directory in C:\wamp\www\php files\files.php on line 25
Call Stack
# Time Memory Function Location
1 0.0008 150912 {main}( ) ..\files.php:0
2 0.0008 151192 processForm( ) ..\files.php:14
3 0.0008 151304 move_uploaded_file ( ) ..\files.php:25

( ! ) Warning: move_uploaded_file(): Unable to move 'C:\wamp\tmp\php513D.tmp' to 'wamp/images.jpg' in C:\wamp\www\php files\files.php on line 25
Call Stack
# Time Memory Function Location
1 0.0008 150912 {main}( ) ..\files.php:0
2 0.0008 151192 processForm( ) ..\files.php:14
3 0.0008 151304 move_uploaded_file ( ) ..\files.php:25
Sorry, there was a problem uploading that photo.

0

2 תשובות

avatar ענה zacharya ב 13 למאי 2013 #

או שתבדוק את הרשאותהתיקייה (777) או שתבדוק שהיא בכלל קיאו שתבדוק את הרשאותהתיקייה (777) או שתבדוק שהיא בכלל קיימת.ימת.

avatar ענה phpon ב 13 למאי 2013 #

הצלחתי!